<template>
  <div class="shouye">
    <!-- 需求是将students数据遍历出来 -->
    <ul>
      <li v-for="item in students" :key="item.id">
        <!-- <router-link :to="{ name: 'itemdetail', params: { id: item.id } }"> -->
        <router-link :to="`/itemdetail/${item.id}`">
          <!-- http://localhost:3000/#/shouye/itemdetail?id=03 -->
          <img :src="item.img" alt="" srcset="" />
          <p>{{ item.name }}</p>
        </router-link>
      </li>
    </ul>
    <button @click="$router.forward()">testForward</button>
    <button @click="$router.back()">返回</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      students: [
        {
          id: "01",
          name: "王洋洋",
          img: require("../assets/img/yangyang.jpg"),
        },
        {
          id: "02",
          name: "chaochao",
          img: require("../assets/img/chaochao.jpg"),
        },
        {
          id: "03",
          name: "jianing",
          img: require("../assets/img/jianing.jpg"),
        },
      ],
    };
  },
};
</script>

<style lang="scss" scoped>
.shouye {
  ul {
    li {
      img {
        width: 200px;
        height: 200px;
      }
    }
  }
}
</style>